package com.ruoyi.hr.service.impl;

import java.util.List;

import com.ruoyi.hr.common.utils.StatusParser;
import com.ruoyi.hr.domain.HrResume;
import com.ruoyi.hr.service.IHrResumeService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import com.ruoyi.hr.mapper.HrBgfileMapper;
import com.ruoyi.hr.domain.HrBgfile;
import com.ruoyi.hr.service.IHrBgfileService;

/**
 * 背调Service业务层处理
 *
 * @author ruoyi
 * @date 2024-08-16
 */
@Service
public class HrBgfileServiceImpl implements IHrBgfileService
{
	@Autowired
	private HrBgfileMapper hrBgfileMapper;

	@Autowired
	private IHrResumeService hrResumeService;

	/**
	 * 查询背调
	 *
	 * @param id 背调主键
	 * @return 背调
	 */
	@Override
	public HrBgfile selectHrBgfileById(Long id)
	{
		return hrBgfileMapper.selectHrBgfileById(id);
	}

	/**
	 * 查询背调列表
	 *
	 * @param hrBgfile 背调
	 * @return 背调
	 */
	@Override
	public List<HrBgfile> selectHrBgfileList(HrBgfile hrBgfile)
	{
		return hrBgfileMapper.selectHrBgfileList(hrBgfile);
	}

	/**
	 * 新增背调
	 *
	 * @param hrBgfile 背调
	 * @return 结果
	 */
	@Override
	public int insertHrBgfile(HrBgfile hrBgfile)
	{
		return hrBgfileMapper.insertHrBgfile(hrBgfile);
	}

	/**
	 * 修改背调
	 *
	 * @param hrBgfile 背调
	 * @return 结果
	 */
	@Override
	public int updateHrBgfile(HrBgfile hrBgfile)
	{
		return hrBgfileMapper.updateHrBgfile(hrBgfile);
	}

	/**
	 * 批量删除背调
	 *
	 * @param ids 需要删除的背调主键
	 * @return 结果
	 */
	@Override
	public int deleteHrBgfileByIds(Long[] ids)
	{
		return hrBgfileMapper.deleteHrBgfileByIds(ids);
	}

	/**
	 * 删除背调信息
	 *
	 * @param id 背调主键
	 * @return 结果
	 */
	@Override
	public int deleteHrBgfileById(Long id)
	{
		return hrBgfileMapper.deleteHrBgfileById(id);
	}

	@Override
	public void pushBgStatus(Long resumeId) {
		HrResume hrResume = hrResumeService.selectHrResumeById(resumeId);

		StatusParser statusParser = new StatusParser(hrResume.getStatus());
		statusParser.setBgStatus(statusParser.getBgStatusCode() + 1);
		HrResume resume = new HrResume();
		resume.setId(resumeId);
		resume.setStatus(statusParser.getStrStatus());
		hrResumeService.updateHrResume(resume);
	}

	@Override
	public HrBgfile selectHrBgfileByResumeId(Long resumeId) {

		return hrBgfileMapper.selectHrBgfileByResumeId(resumeId);
	}
}
